package org.zht.dormpro.dorm.cacher.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import org.zht.dormpro.dorm.aop.annotation.GetCache;
import org.zht.dormpro.dorm.cacher.ICollegeCacher;
import org.zht.dormpro.dorm.mapper.TbCollegeMapper;
import org.zht.dormpro.dorm.model.TbCollege;
import org.zht.dormpro.pub.constant.CacheKey;

import java.util.List;

@Repository
public class CollegeCacherImpl implements ICollegeCacher {

    @Autowired
    private TbCollegeMapper collegeMapper;

    /**
     * 从缓存中获取学院列表
     */
    @Override
    @GetCache(key = CacheKey.COLLEGE_LIST_KEY, type = List.class )
    public List<TbCollege> getAllCollege(){
        //缓存的话我只需要缓存可以用的学院信息,所以传入1就行了
        List<TbCollege> allCollege = collegeMapper.getAllCollege(1);
        return allCollege;
    }
}
